<!DOCTYPE HTML>
<html lang="zh-CN">



<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Java中的String字符串及其常用方法, 颖火虫赵云">
    <meta name="description" content="分享各类技术文章，java python等">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>Java中的String字符串及其常用方法 | 颖火虫赵云</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">


    <script src="/libs/jquery/jquery.min.js"></script>


<meta name="generator" content="Hexo 5.3.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
<link rel="alternate" href="/atom.xml" title="颖火虫赵云" type="application/atom+xml">
</head>







    
        

<style type="text/css" lang="css">
    #loading-container {
        position: fixed;
        top: 0;
        left: 0;
        min-height: 100vh;
        width: 100vw;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #FFF;
        text-align: center;
        /* loader页面消失采用渐隐的方式*/
        -webkit-transition: opacity 1s ease;
        -moz-transition: opacity 1s ease;
        -o-transition: opacity 1s ease;
        transition: opacity 1s ease;
    }

    .loading-image {
        width: 120px;
        height: 50px;
        transform: translate(-50%);
    }

    .loading-image div:nth-child(2) {
        -webkit-animation: pacman-balls 1s linear 0s infinite;
        animation: pacman-balls 1s linear 0s infinite
    }

    .loading-image div:nth-child(3) {
        -webkit-animation: pacman-balls 1s linear .33s infinite;
        animation: pacman-balls 1s linear .33s infinite
    }

    .loading-image div:nth-child(4) {
        -webkit-animation: pacman-balls 1s linear .66s infinite;
        animation: pacman-balls 1s linear .66s infinite
    }

    .loading-image div:nth-child(5) {
        -webkit-animation: pacman-balls 1s linear .99s infinite;
        animation: pacman-balls 1s linear .99s infinite
    }

    .loading-image div:first-of-type {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
        animation: rotate_pacman_half_up .5s 0s infinite;
    }

    .loading-image div:nth-child(2) {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
        animation: rotate_pacman_half_down .5s 0s infinite;
        margin-top: -50px;
    }

    @-webkit-keyframes rotate_pacman_half_up {
        0% {
            transform: rotate(270deg)
        }

        50% {
            transform: rotate(1turn)
        }

        to {
            transform: rotate(270deg)
        }
    }

    @keyframes rotate_pacman_half_up {
        0% {
            transform: rotate(270deg)
        }

        50% {
            transform: rotate(1turn)
        }

        to {
            transform: rotate(270deg)
        }
    }

    @-webkit-keyframes rotate_pacman_half_down {
        0% {
            transform: rotate(90deg)
        }

        50% {
            transform: rotate(0deg)
        }

        to {
            transform: rotate(90deg)
        }
    }

    @keyframes rotate_pacman_half_down {
        0% {
            transform: rotate(90deg)
        }

        50% {
            transform: rotate(0deg)
        }

        to {
            transform: rotate(90deg)
        }
    }

    @-webkit-keyframes pacman-balls {
        75% {
            opacity: .7
        }

        to {
            transform: translate(-100px, -6.25px)
        }
    }

    @keyframes pacman-balls {
        75% {
            opacity: .7
        }

        to {
            transform: translate(-100px, -6.25px)
        }
    }

    .loading-image div:nth-child(3),
    .loading-image div:nth-child(4),
    .loading-image div:nth-child(5),
    .loading-image div:nth-child(6) {
        background-color: #49b1f5;
        width: 15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        width: 10px;
        height: 10px;
        position: absolute;
        transform: translateY(-6.25px);
        top: 25px;
        left: 100px;
    }

    .loading-text {
        margin-bottom: 20vh;
        text-align: center;
        color: #2c3e50;
        font-size: 2rem;
        box-sizing: border-box;
        padding: 0 10px;
        text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }

    @media only screen and (max-width: 500px) {
        .loading-text {
            font-size: 1.5rem;
        }
    }

    .fadeout {
        opacity: 0;
        filter: alpha(opacity=0);
    }


   

    /* logo出现动画 */
    @-webkit-keyframes fadeInDown {
        0% {
            opacity: 0;
            -webkit-transform: translate3d(0, -100%, 0);
            transform: translate3d(0, -100%, 0)
        }

        100% {
            opacity: 1;
            -webkit-transform: none;
            transform: none
        }
    }

    @keyframes fadeInDown {
        0% {
            opacity: 0;
            -webkit-transform: translate3d(0, -100%, 0);
        }
    }
</style>
<script> (function () {
        const loaded = function () {
            setTimeout(function () {
                const loader = document.getElementById("loading-container"); loader.className = "fadeout";//使用渐隐的方法淡出loading page // 
                //document.getElementById("body-wrap").style.display="flex"; 
                setTimeout(function () {
                    loader.style.display = "none";
                }, 2500);
            }, 1000);//强制显示loading page 1s 
        };
        loaded();
    }
    )() </script>







            

                <body>

                    
                    

                        
                                <div id="loading-container">
                                    <p class="loading-text">嘘~ lsp正在从服务器偷取页面 . . . </p>
                                    <div class="loading-image">
                                        <div></div>
                                        <div></div>
                                        <div></div>
                                        <div></div>
                                        <div></div>
                                    </div>
                                </div>
                                
                                

                                    


                                                <body>


                                                    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                        <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                        
                            <span class="logo-span">
                                颖火虫赵云
                            </span>

                            
                </a>

            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/index.html" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags/" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about/" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于我</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/navigate" class="waves-effect waves-light">
      
      <i class="fas fa-location-arrow" style="zoom: 0.6;"></i>
      
      <span>导航</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">颖火虫赵云</div>
        <div class="logo-desc">
            
            分享各类技术文章，java python等
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/index.html" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于我
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/navigate" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-location-arrow"></i>
			
			导航
		</a>
          
        </li>
        
        
    </ul>

</div>


        </div>

        

    </nav>
    

</header>



                                                        



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/7.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">Java中的String字符串及其常用方法</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                          <div class="article-tag">
                            <span class="chip bg-color">无标签</span>
                          </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-12-31
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2020-12-31
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    4.3k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    17 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>字符串是常量，字符串对象一旦被创建，其值是不能改变的，这是因为字符串的值是存放在方法区的常量池里面，但是引用可以改变，并且可以使用其他变量重新赋值的方式进行更改。<br>java字符串String是不可变对象；<br>字符串操作不改变元字符串内容，而是返回新字符串<br>Java使用Unicode编码表示String和char；<br>转换编码就是将String和byte[]转换，需要指定编码；<br>转换为byte[]时，始终优先考虑UTF-8编码。<br>直接定义字符串<br>直接定义字符串是指使用双引号表示字符串中的内容，例如“Hello Java”、“Java 编程”等。具体方法是用字符串常量直接初始化一个 String 对象，示例如下：</p>
<blockquote>
<p>String str = “Hello Java”;<br>1<br>下面的实例演示了直接创建字符串的几种用法。</p>
</blockquote>
<pre class="language-none"><code class="language-none">String str = "我是一只小小鸟"; // 结果：我是一只小小鸟
String word;
word = "I am a bird"; // 结果：I am a bird
word = "&lt;h1&gt;to fly&lt;/h1&gt;"; // 结果：&lt;h1&gt;to fly&lt;/h1&gt;
word = "Let\'s say that it\'s true"; // 结果：Let's say that it's true
System.out.println(word);
word = "北京\\上海\\广州"; // 结果：北京\上海\广州</code></pre>
<h1 id="常用方法"><a href="#常用方法" class="headerlink" title="常用方法"></a>常用方法</h1><h3 id="字符串长度"><a href="#字符串长度" class="headerlink" title="字符串长度"></a>字符串长度</h3><p>用于获取有关对象的信息的方法称为访问器方法。</p>
<p>String 类的一个访问器方法是 length() 方法，它返回字符串对象包含的字符数。</p>
<p>下面的代码执行后，len 变量等于 14:</p>
<p>StringDemo.java 文件代码：</p>
<pre class="language-none"><code class="language-none">public class StringDemo {
    public static void main(String args[]) {
        String site = "www.runoob.com";
        int len = site.length();
        System.out.println( "菜鸟教程网址长度 : " + len );
   }
}</code></pre>
<p>以上实例编译运行结果如下：</p>
<p><strong>菜鸟教程网址长度 : 14</strong></p>
<h3 id="toLowerCase-amp-toUpperCase-方法"><a href="#toLowerCase-amp-toUpperCase-方法" class="headerlink" title="toLowerCase() &amp; toUpperCase()方法"></a>toLowerCase() &amp; toUpperCase()方法</h3><p>String 类的 toLowerCase() 方法可以将字符串中的所有字符全部转换成小写，而非字母的字符不受影响。语法格式如下：<br>字符串名.toLowerCase() // 将字符串中的字母全部转换为小写，非字母不受影响</p>
<p>toUpperCase() 则将字符串中的所有字符全部转换成大写，而非字母的字符不受影响。语法格式如下：<br>字符串名.toUpperCase() // 将字符串中的字母全部转换为大写，非字母不受影响</p>
<p>例如：</p>
<pre class="language-none"><code class="language-none">String str="abcdef 我 ghijklmn";
System.out.println(str.toLowerCase());    // 输出：abcdef 我 ghijklmn
System.out.println(str.toUpperCase());    // 输出：ABCDEF 我 GHIJKLMN</code></pre>
<h3 id="trim-方法去除空格"><a href="#trim-方法去除空格" class="headerlink" title="trim()方法去除空格"></a>trim()方法去除空格</h3><p>字符串中存在的首尾空格一般情况下都没有任何意义，如字符串“ Hello ”，但是这些空格会影响到字符串的操作，如连接字符串或比较字符串等，所以应该去掉字符串中的首尾空格，这需要使用 String 类提供的 trim() 方法。</p>
<p>trim() 方法的语法形式如下：</p>
<p>字符串名.trim()<br>1<br>使用 trim() 方法的示例如下：</p>
<pre class="language-none"><code class="language-none">String str = " hello ";
System.out.println(str.length());    // 输出 7
System.out.println(str.trim().length());    // 输出 5</code></pre>
<p>从该示例中可以看出，字符串中的每个空格占一个位置，直接影响了计算字符串的长度。</p>
<p>如果不确定要操作的字符串首尾是否有空格，最好在操作之前调用该字符串的 trim() 方法去除首尾空格，然后再对其进行操作。</p>
<p>注意：trim() 只能去掉字符串中前后的半角空格（英文空格），而无法去掉全角空格（中文空格）。可用以下代码将全角空格替换为半角空格再进行操作，其中替换是 String 类的 replace() 方法</p>
<pre class="language-none"><code class="language-none">str = str.replace((char) 12288, ' ');    // 将中文空格替换为英文空格
str = str.trim();</code></pre>
<p>其中，12288 是中文全角空格的 unicode 编码。</p>
<h3 id="判空"><a href="#判空" class="headerlink" title="判空"></a>判空</h3><p>String 还提供了isEmpty()和isBlank()来判断字符串是否为空和空白字符串：</p>
<h3 id="类型转换"><a href="#类型转换" class="headerlink" title="类型转换"></a>类型转换</h3><h4 id="String转换为int"><a href="#String转换为int" class="headerlink" title="String转换为int"></a>String转换为int</h4><p>String 字符串转整型 int 有以下两种方式：</p>
<blockquote>
<p>Integer.parseInt(str)<br>Integer.valueOf(str).intValue()</p>
</blockquote>
<p>注意：Integer 是一个类，是 int 基本数据类型的封装类。在《Java Integer类》一节中我们会详细讲解。</p>
<p>例如下面代码所示：</p>
<pre class="language-none"><code class="language-none">public static void main(String[] args) {
    String str = "123";
    int n = 0;
    // 第一种转换方法：Integer.parseInt(str)
    n = Integer.parseInt(str);
    System.out.println("Integer.parseInt(str) : " + n);
    // 第二种转换方法：Integer.valueOf(str).intValue()
    n = 0;
    n = Integer.valueOf(str).intValue();
    System.out.println("Integer.parseInt(str) : " + n);
}
输出结果为：
Integer.parseInt(str) : 123
Integer.parseInt(str) : 123</code></pre>
<p>在 String 转换 int 时，String 的值一定是整数，否则会报数字转换异常（java.lang.NumberFormatException）。</p>
<h4 id="int转换为String"><a href="#int转换为String" class="headerlink" title="int转换为String"></a>int转换为String</h4><p>整型 int 转 String 字符串类型有以下 3 种方法：</p>
<p>String s = String.valueOf(i);<br>String s = Integer.toString(i);<br>String s = “” + i;</p>
<p>例如下面代码所示：</p>
<pre class="language-none"><code class="language-none">public static void main(String[] args) {
    int num = 10;
    // 第一种方法：String.valueOf(i);
    num = 10;
    String str = String.valueOf(num);
    System.out.println("str:" + str);
    // 第二种方法：Integer.toString(i);
    num = 10;
    String str2 = Integer.toString(num);
    System.out.println("str2:" + str2);
    // 第三种方法："" + i;
    String str3 = num + "";
    System.out.println("str3:" + str3);
}
输出结果为：
str:10
str2:10
str3:10</code></pre>
<p>使用第三种方法相对第一第二种耗时比较大。在使用第一种 valueOf() 方法时，注意 valueOf 括号中的值不能为空，否则会报空指针异常（NullPointerException）。</p>
<h4 id="任意类型转换为字符串"><a href="#任意类型转换为字符串" class="headerlink" title="任意类型转换为字符串:"></a>任意类型转换为字符串:</h4><p>要把任意基本类型或引用类型转换为字符串，可以使用静态方法valueOf()。这是一个重载方法，编译器会根据参数自动选择合适的方法.</p>
<pre class="language-none"><code class="language-none">String.valueOf(123); // "123" 
String.valueOf(45.67); // "45.67"
String.valueOf(true); // "true" 
String.valueOf(new Object()); // 类似java.lang.Object@636be97c</code></pre>
<h4 id="字符串转换其他类型"><a href="#字符串转换其他类型" class="headerlink" title="字符串转换其他类型:"></a>字符串转换其他类型:</h4><p>视情况而论</p>
<pre class="language-none"><code class="language-none">int n1 = Integer.parseInt("123"); // 123
int n2 = Integer.parseInt("ff", 16); // 按十六进制转换，255

//String和char[]类型可以互相转换
char[] cf = "Hello".toCharArray(); // String -&gt; char[]
String s = new String(cf); // char[] -&gt; String</code></pre>
<h3 id="截取（提取）子字符串-substring"><a href="#截取（提取）子字符串-substring" class="headerlink" title="截取（提取）子字符串 substring()"></a>截取（提取）子字符串 substring()</h3><p>substring(int beginIndex) 形式<br>此方式用于提取从索引位置开始至结尾处的字符串部分。调用时，括号中是需要提取字符串的开始位置，方法的返回值是提取的字符串。例如：</p>
<pre class="language-none"><code class="language-none">String str = "我爱 Java 编程";
String result = str.substring(3);
System.out.println(result);    // 输出：Java 编程</code></pre>
<p>substring(int beginIndex，int endIndex) 形式<br>此方法中的 beginIndex 表示截取的起始索引，截取的字符串中包括起始索引对应的字符；endIndex 表示结束索引，截取的字符串中不包括结束索引对应的字符 即（前闭后开）原则，如果不指定 endIndex，则表示截取到目标字符串末尾。该方法用于提取位置 beginIndex 到 endIndex-1的字符串部分。<br>注意 ：这里的结束位置是包括的，因为结束索引是从1开始的，开始索引从零开始，这是另一种理解方式，大家选哪种理解都行，还有前闭后开原则，大家选一种理解即可，后面也有说明！！</p>
<p>这里需要特别注意的是， 对于开始位置 beginIndex， Java 是基于字符串的首字符索引为 0 处理的，但是对于结束位置 endIndex，Java 是基于字符串的首字符索引为 1 来处理的，如图 1 所示。</p>
<p>参数</p>
<p>beginIndex – 起始索引（包括）, 索引从 0 开始。</p>
<p>endIndex – 结束索引（不包括结束索引）。</p>
<p>返回值</p>
<p><img src="https://img-blog.csdnimg.cn/20200528212651496.png" alt="字符串中的字符索引" title="字符串的字符索引"></p>
<p><strong>结尾索引理解三种都行 ，用首字符索引为1理解也行，用不包括结尾索引理解也行 另有beginIndex 到 endIndex-1理解也可以 。</strong><br>注意：substring() 方法是按字符截取，而不是按字节截取。<br>例 1<br>创建一个字符串，对它使用 substring() 方法进行截取并输出结果。示例代码如下：</p>
<pre class="language-none"><code class="language-none">public static void main(String[] args) {
    String day = "Today is Monday";    //原始字符串
    System.out.println("substring(0)结果："+day.substring(0));
    System.out.println("substring(2)结果："+day.substring(2));
    System.out.println("substring(10)结果："+day.substring(10));
    System.out.println("substring(2,10)结果："+day.substring(2,10));
    System.out.println("substring(0,5)结果："+day.substring(0,5));
}

输出结果如下所示：
substring(0)结果：Today is Monday
substring(2)结果：day is Monday
substring(10)结果：onday
substring(2,10)结果：day is M
substring(0,5)结果：Today</code></pre>
<h3 id="替代方法"><a href="#替代方法" class="headerlink" title="替代方法"></a>替代方法</h3><h4 id="replace-方法"><a href="#replace-方法" class="headerlink" title="replace() 方法"></a>replace() 方法</h4><p>replace() 方法用于将目标字符串中的指定字符（串）替换成新的字符（串），其语法格式如下：</p>
<p>字符串.replace(String oldChar, String newChar)</p>
<p>其中，oldChar 表示被替换的字符串；newChar 表示用于替换的字符串。replace() 方法会将字符串中所有 oldChar 替换成 newChar。<br>例 1<br>创建一个字符串，对它使用 replace() 方法进行字符串替换并输出结果。代码如下：</p>
<pre class="language-none"><code class="language-none">public static void main(String[] args) {
    String words = "hello java,hello php";
    System.out.println("原始字符串是'"+words+"'");
    System.out.println("replace(\"l\",\"D\")结果："+words.replace("l","D"));
    System.out.println("replace(\"hello\",\"你好\")结果："+words.replace("hello","你好 "));
    words = "hr's dog";
    System.out.println("原始字符串是'"+words+"'");
    System.out.println("replace(\"r's\",\"is\")结果："+words.replace("r's","is"));
}

输出结果如下所示：
原始字符串是’hello java,hello php’
replace(“l”,“D”)结果：heDDo java,heDDo php
replace(“hello”,“你好”)结果：你好 java,你好 php
原始字符串是’hr’s dog’
replace(“r’s”,“is”)结果：his dog</code></pre>
<h4 id="replaceFirst-方法"><a href="#replaceFirst-方法" class="headerlink" title="replaceFirst() 方法"></a>replaceFirst() 方法</h4><p>replaceFirst() 方法用于将目标字符串中匹配某正则表达式的第一个子字符串替换成新的字符串，其语法形式如下：</p>
<p>字符串.replaceFirst(String regex, String replacement)</p>
<p>其中，regex 表示正则表达式；replacement 表示用于替换的字符串。例如：</p>
<p>String words = “hello java，hello php”;<br>String newStr = words.replaceFirst(“hello”,”你好 “);<br>System.out.println(newStr);    // 输出：你好 java,hello php</p>
<h4 id="replaceAll-方法"><a href="#replaceAll-方法" class="headerlink" title="replaceAll() 方法"></a>replaceAll() 方法</h4><p>replaceAll() 方法用于将目标字符串中匹配某正则表达式的所有子字符串替换成新的字符串，其语法形式如下：</p>
<p>字符串.replaceAll(String regex, String replacement)</p>
<p>其中，regex 表示正则表达式，replacement 表示用于替换的字符串。例如：</p>
<p>String words = “hello java，hello php”;<br>String newStr = words.replaceAll(“hello”,”你好 “);<br>System.out.println(newStr);    // 输出：你好 java,你好 php</p>
<h3 id="字符串查找"><a href="#字符串查找" class="headerlink" title="字符串查找"></a>字符串查找</h3><p>字符串查找分为两种形式：</p>
<p>在字符串中获取匹配字符（串）的索引值<br>在字符串中获取指定索引位置的字符<br>根据字符查找<br>String 类的 indexOf() 方法和 lastlndexOf() 方法用于在字符串中获取匹配字符（串）的索引值。</p>
<h4 id="1-indexOf-方法"><a href="#1-indexOf-方法" class="headerlink" title="1. indexOf() 方法"></a>1. indexOf() 方法</h4><p>indexOf() 方法用于返回字符（串）在指定字符串中首次出现的索引位置，如果能找到，则返回索引值，否则返回 -1。该方法主要有两种重载形式：<br>str.indexOf(value)<br>str.indexOf(value,int fromIndex)</p>
<p>其中，str 表示指定字符串；value 表示待查找的字符（串）；fromIndex 表示查找时的起始索引，如果不指定 fromIndex，则默认从指定字符串中的开始位置（即 fromIndex 默认为 0）开始查找。</p>
<p>例如，下列代码在字符串“Hello Java”中查找字母 v 的索引位置。</p>
<p>String s = “Hello Java”;<br>int size = s.indexOf(‘v’);    // size的结果为8</p>
<p>上述代码执行后 size 的结果为 8，它的查找过程如图 1 所示。</p>
<p>例 1<br>编写一个简单的 Java 程序，演示 indexOf() 方法查找字符串的用法，并输出结果。代码如下：</p>
<pre class="language-none"><code class="language-none">public static void main(String[] args) {
    String words = "today,monday,sunday";
    System.out.println("原始字符串是'"+words+"'");
    System.out.println("indexOf(\"day\")结果："+words.indexOf("day"));
    System.out.println("indexOf(\"day\",5)结果："+words.indexOf("day",5));
    System.out.println("indexOf(\"o\")结果："+words.indexOf("o"));
    System.out.println("indexOf(\"o\",6)结果："+words.indexOf("o",6));
}


运行后的输出结果如下：
原始字符串是’today,monday,sunday’
indexOf(“day”)结果：2
indexOf(“day”,5)结果：9
indexOf(“o”)结果：1
indexOf(“o”,6)结果：7</code></pre>
<h4 id="2-lastlndexOf-方法"><a href="#2-lastlndexOf-方法" class="headerlink" title="2. lastlndexOf() 方法"></a>2. lastlndexOf() 方法</h4><p>lastIndexOf() 方法用于返回字符（串）在指定字符串中最后一次出现的索引位置，如果能找到则返回索引值，否则返回 -1。该方法也有两种重载形式：<br>str.lastIndexOf(value)<br>str.lastlndexOf(value, int fromIndex)</p>
<p>注意：lastIndexOf() 方法的查找策略是从右往左查找，如果不指定起始索引，则默认从字符串的末尾开始查找。<br>例 2<br>编写一个简单的 Java 程序，演示 lastIndexOf() 方法查找字符串的用法，并输出结果。代码如下：</p>
<pre class="language-none"><code class="language-none">public static void main(String[] args) {
    String words="today,monday,Sunday";
    System.out.println("原始字符串是'"+words+"'");
    System.out.println("lastIndexOf(\"day\")结果："+words.lastIndexOf("day"));
    System.out.println("lastIndexOf(\"day\",5)结果："+words.lastIndexOf("day",5));
    System.out.println("lastIndexOf(\"o\")结果："+words.lastIndexOf("o"));
    System.out.println("lastlndexOf(\"o\",6)结果："+words.lastIndexOf("o",6));
}

运行后的输出结果如下：
原始字符串是’today,monday,Sunday’
lastIndexOf(“day”)结果：16
lastIndexOf(“day”,5)结果：2
lastIndexOf(“o”)结果：7
lastlndexOf(“o”,6)结果：1</code></pre>
<h3 id="根据索引查找"><a href="#根据索引查找" class="headerlink" title="根据索引查找"></a>根据索引查找</h3><p>String 类的 charAt() 方法可以在字符串内根据指定的索引查找字符，该方法的语法形式如下：</p>
<p>字符串名.charAt(索引值)</p>
<p>提示：字符串本质上是字符数组，因此它也有索引，索引从零开始。</p>
<p>charAt() 方法的使用示例如下：</p>
<p>String words = “today,monday,sunday”;<br>System.out.println(words.charAt(0));    // 结果：t<br>System.out.println(words.charAt(1));    // 结果：o<br>System.out.println(words.charAt(8));    // 结果：n</p>
<h2 id="1-常见String类的获取功能"><a href="#1-常见String类的获取功能" class="headerlink" title="1.常见String类的获取功能"></a>1.常见String类的获取功能</h2><p>public int length(): 获取字符串的长度。<br>public char charAt(int index): 获取指定索引位置的字符<br>public int indexOf(int ch): 返回指定字符在此字符串中第一次出现处的索引。<br>public int indexOf(String str): 返回指定子字符串在此字符串中第一次出现处的索引。<br>public int indexOf(int ch,int fromIndex):返回指定字符在此字符串中从指定位置后第一次出现处的索引。<br>public int indexOf(String str,int fromIndex): 返回指定子字符串在此字符串中从指定位置后第一次出现处的索引。<br>public String substring(int beginIndex): 从指定位置开始截取字符串,默认到末尾。<br>public String substring(int beginIndex, int endIndex): 返回一个新字符串从指定位置开始到指定位置结束截取字符串。（beginIndex 到 endIndex -1的所有字符）</p>
<h2 id="2-常见String类的判断功能"><a href="#2-常见String类的判断功能" class="headerlink" title="2.常见String类的判断功能"></a>2.常见String类的判断功能</h2><p>public boolean equals(Object obj): 比较字符串的内容是否相同,区分大小写<br>public boolean equalsIgnoreCase(String str): 比较字符串的内容是否相同,忽略大小写<br>public boolean contains(String str): 判断字符串中是否包含传递进来的字符串，即当且仅当此字符串包含指定的 char 值序列时（此字符串包含 str则），返回 true。<br>public boolean startsWith(String str): 判断字符串是否以指定的的字符串开头<br>boolean startsWith(String prefix, int toffset)：测试此字符串从指定索引开始的子字符串是否以指定前缀开始。<br>public boolean endsWith(String str): 判断字符串是否以传递进来的字符串结尾<br>public boolean isEmpty(): 判断字符串的内容是否为空串。</p>
<h2 id="3-常见String类的转换功能"><a href="#3-常见String类的转换功能" class="headerlink" title="3.常见String类的转换功能"></a>3.常见String类的转换功能</h2><p>public byte[] getBytes(): 把字符串转换为字节数组。<br>public char[] toCharArray(): 把字符串转换为字符数组。<br>public static String valueOf(char[] chs): 把字符数组转成字符串。<br>public static String valueOf(int i): 把int类型的数据转成字符串。（String类的valueOf方法可以把任意类型的数据转成字符串。）<br>public String toLowerCase(): 把字符串转成小写。使用默认语言环境的规则将此 String 中的所有字符都转换为小写。<br>public String toUpperCase(): 把字符串转成大写。 使用默认语言环境的规则将此 String 中的所有字符都转换为大写。<br>public String concat(String str): 把字符串拼接。将指定字符串连接到此字符串的结尾。</p>
<h2 id="4-常见String类的其他常用功能"><a href="#4-常见String类的其他常用功能" class="headerlink" title="4.常见String类的其他常用功能"></a>4.常见String类的其他常用功能</h2><p>public String replace(char oldChar, char newChar)：返回一个新的字符串，它是通过用 newChar 替换此字符串中出现的所有 oldChar 得到的。<br>public String replace(String old,String new) ：将指定字符串进行互换<br>public String trim() 去除两端空格<br>public int compareTo(Object o) : 把这个字符串和另一个对象比较。<br>public int compareTo(String anotherString) : 按字典顺序比较两个字符串。<br>public int compareToIgnoreCase(String str): 按字典顺序比较两个字符串，不考虑大小写。</p>
<h2 id="其他方法"><a href="#其他方法" class="headerlink" title="其他方法"></a>其他方法</h2><p>SN(序号) |||| 方法描述</p>
<p>boolean contentEquals(StringBuffer sb): 当且仅当字符串与指定的StringBuffer有相同顺序的字符时候返回真。</p>
<p>static String copyValueOf(char[] data): 返回指定数组中表示该字符序列的 String。</p>
<p>static String copyValueOf(char[] data, int offset, int count): 返回指定数组中表示该字符序列的 String。</p>
<p>void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin): 将字符从此字符串复制到目标字符数组。</p>
<p>String intern()：返回字符串对象的规范化表示形式。</p>
<p>int lastIndexOf(int ch)： 返回指定字符在此字符串中最后一次出现处的索引。</p>
<p>int lastIndexOf(int ch, int fromIndex)：返回指定字符在此字符串中最后一次出现处的索引，从指定的索引处开始进行反向搜索。</p>
<p>int lastIndexOf(String str)<br>返回指定子字符串在此字符串中最右边出现处的索引。</p>
<p>int lastIndexOf(String str, int fromIndex)<br>返回指定子字符串在此字符串中最后一次出现处的索引，从指定的索引开始反向搜索。</p>
<p>String toString()<br>返回此对象本身（它已经是一个字符串！）。</p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">颖火虫-IT赵云</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://zly520xb.gitee.io/2020/12/31/java-zhong-de-string-zi-fu-chuan-ji-qi-chang-yong-fang-fa/">https://zly520xb.gitee.io/2020/12/31/java-zhong-de-string-zi-fu-chuan-ji-qi-chang-yong-fang-fa/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">颖火虫-IT赵云</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            <span class="chip bg-color">无标签</span>
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    
        <style>
    .mvaline-card {
        margin: 1.5rem auto;
    }

    .mvaline-card .card-content {
        padding: 20px 20px 5px 20px;
    }
</style>

<div class="card mvaline-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; padding-left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="mvcomments" class="card-content" style="display: grid">
    </div>
</div>

<script src="/libs/minivaline/MiniValine.js"></script>
<script>
    new MiniValine({
        el: '#mvcomments',
        appId: 'ddp0v6AnFMKCl5TNYie9PKcA-MdYXbMMI',
        appKey: 'WDxeJI3PQqQLndzfBj8LGQ9k',
        mode: 'DesertsP',
        placeholder: 'Write a Comment',
        pathname: window.location.pathname,
        lang: '',
        adminEmailMd5: 'de8a7aa53d07e6b6bceb45c64027763d',
        tagMeta: ["管理员", "小伙伴", "访客"],
        master: ["de8a7aa53d07e6b6bceb45c64027763d"],
        friends: ["b5bd5d836c7a0091aa8473e79ed4c25e", "adb7d1cd192658a55c0ad22a3309cecf", "3ce1e6c77b4910f1871106cb30dc62b0", "cfce8dc43725cc14ffcd9fb4892d5bfc"],
        math: true,
        md: true,
        enableQQ: true,
        NoRecordIP: false,
        visitor: true,
        maxNest: 6,
        pageSize: 6,
        serverURLs: '',
        emoticonUrl: ["https://cdn.jsdelivr.net/npm/alus@latest", "https://cdn.jsdelivr.net/gh/MiniValine/qq@latest", "https://cdn.jsdelivr.net/gh/MiniValine/Bilibilis@latest", "https://cdn.jsdelivr.net/gh/MiniValine/tieba@latest", "https://cdn.jsdelivr.net/gh/MiniValine/twemoji@latest", "https://cdn.jsdelivr.net/gh/MiniValine/weibo@latest"],
    });
</script>

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="far fa-dot-circle"></i>&nbsp;本篇
            </div>
            <div class="card">
                <a href="/2020/12/31/java-zhong-de-string-zi-fu-chuan-ji-qi-chang-yong-fang-fa/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/7.jpg" class="responsive-img" alt="Java中的String字符串及其常用方法">
                        
                        <span class="card-title">Java中的String字符串及其常用方法</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-12-31
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            颖火虫-IT赵云
                            
                        </span>
                    </div>
                </div>

                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/12/20/hello-world/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/12.jpg" class="responsive-img" alt="Hello World">
                        
                        <span class="card-title">Hello World</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-12-20
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            颖火虫-IT赵云
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('120')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + '来源: 颖火虫赵云<br />'
            + '文章作者: 颖火虫-IT赵云<br />'
            + '文章链接: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>


<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




                                                            
<footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<script src="https://activity.kugou.com/vo-activity/fa339ef0-2270-11ea-8b2a-c3556712becb/dist/kgPlayerV2.min.js"></script>


<script>
    var kgplay = window.kgPlayerV2;
//初始化播放器配置
kgplay.player.initPlayer({
    appid,//open.kugou.com颁发的appid
    ticket,//有效凭证，见最底部"服务端获取ticket"
    loadTime: 5000,//加载超时时长
    playTime: 5000//播放超时时长
})
//单曲播放（覆盖歌曲列表）
kgplay.player.playSong({
    hash, //歌曲HASH
    album_audio_id,//歌曲album_audio_id
    noClimax: false//默认播放高潮点
})
//多首播放（覆盖歌曲列表）
kgplay.player.playSong([
    {hash,album_audio_id},
    {hash,album_audio_id}
])
//追加歌曲到歌曲列表头部并播放
kgplay.player.playSong([
    {hash,album_audio_id},
    {hash,album_audio_id}
],{
    type:"add"
})
//增加歌曲到歌曲列表尾（不播放）
kgplay.player.addSongList([
    {hash,album_audio_id},
    {hash,album_audio_id}
])
//增加歌曲到歌曲列表指定位置（不播放）
kgplay.player.addSongList([
    {hash,album_audio_id},
    {hash,album_audio_id}
],{
    pos:0
})
//播放歌曲列表的某一首
kgplay.player.playSong(1)
//播放歌曲 
kgplay.player.play()
//暂停歌曲 
kgplay.player.pause()
//暂停/播放歌曲 
kgplay.player.toggle()
//获取播放状态(pause | play)
kgplay.player.getPlayStatus()
//获取歌曲信息
kgplay.player.getSongInfo()
//播放下一首
kgplay.player.playNext()
//播放上一首
kgplay.player.playPrev()
//改变播放模式
//列表循环：cycle(默认)
//顺序播放：loop
//单曲播放：once
//随机播放：random
kgplay.player.changePlayMode("cycle")
//跳转播放页 （不填参数则默认跳转当前播放的歌曲）
kgplay.player.jump(hash,album_audio_id)
//销毁歌曲+挂件（调用playSong后恢复）
kgPlayer.player.destroy()
//原生音频事件监听
kgplay.player.addEvent
//比如：
kgplay.player.addEvent("play", function (data,event) {
    //播放监听
})
kgplay.player.addEvent("pause", function (data,event) {
    //暂停监听
})
//非原生音频事件监听
kgplay.listener.listen("audioPlayFail", function (data) {
    //audio播放失败
})
kgplay.listener.listen("playSongSuccess", function (data) {
    //播放成功
})
kgplay.listener.listen("playSongFail", function (data) {
    //播放失败
})
kgplay.listener.listen("playSongTimeout", function (data) {
    //播放超时
})
kgplay.listener.listen("playSongEnded", function (data) {
    //播放结束
})
kgplay.listener.listen("loadSongSuccess", function (data) {
    //加载成功
})
kgplay.listener.listen("loadSongFail", function (data) {
    //加载失败
})
kgplay.listener.listen("loadSongTimeout", function (data) {
    //加载超时
})
var kgplay = window.kgPlayerV2;
//初始化搜索配置
 kgplay.search.initSearch({
    appid, //open.kugou.com颁发的appid
    ticket, //有效凭证，见最底部"服务端获取ticket"
 })
//显示搜索
kgplay.search.show()
//内嵌显示搜索
kgplay.search.show({
    type: "inner",
    id: "DOM容器ID"，
    close:true//是否显示搜索关闭按钮
})
//跳转方式显示搜索
kgplay.search.show({
    type: "jump"
})
//关闭搜索
kgplay.search.hide()
//监听
kgplay.listener.listen("childChoiceSongCallback", function (data) {
    //搜索页选择歌曲后通知调用页
    //播放歌曲
    kgplay.player.playSong({
        hash: data.hash,
        album_audio_id: data.album_audio_id
    })
    //或者...
    kgplay.player.playSong({
        hash: data.hash,
        album_audio_id: data.album_audio_id
    },{
        type:"add"
    })
})
var kgplay = window.kgPlayerV2;
//显示完整挂件
kgplay.bar.fullBar()
//显示mini挂件
kgplay.bar.miniBar()
//设置挂件皮肤
kgPlayer.bar.setSkin({
    //面板背景色
    panel: "#093594",
    //歌曲名文字颜色
    song: "#FFFFFF",
    //跳转链接文字颜色
    jump: "#00BAFF"
})
</script>
<style>
    .aplayer .aplayer-lrc p {
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 15px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2020-2021</span>
            


            
            <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
             <style>.fa-heart{font-size:30px;color:rgba(224, 21, 21, 0.1);
                animation:donghua .3s 0s infinite linear reverse}
                @keyframes donghua{
                    from{color:rgba(124, 11, 11, 0.1)}to{color:rgb(126, 21, 7)}
                    }</style>
                   
                    <body>
                        <li class="fa fa-heart"></li>
                    </body> 
                
                     
                
            </style> 
           
            <i class="fa fa-heartbeat" aria-hidden="true"></i>

            <a href="/about" target="_blank">颖火虫-IT赵云</a>
            <!-- |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a> -->
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">4.4k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>




    
<!-- 新增访客统计代码 END-->
            
            <br>
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2020";
                    var startMonth = "12";
                    var startDate = "20";
                    var startHour = "20";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            
            <span id="icp"><img src="/medias/icp.png" style="vertical-align: text-bottom;" />
                <a href="https://lnca.miit.gov.cn/" target="_blank">辽ICP备2021001693号-1</a>
            </span>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/qazhw" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:1246192877@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1246192877" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1246192877" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>



    <a href="https://blog.csdn.net/q1246192888" class="tooltipped" target="_blank" data-tooltip="关注我的CSDN: https://blog.csdn.net/q1246192888" data-position="top" data-delay="50">
        <i class="fab fa-csdn">C</i>
    </a>



    <a href="https://www.cnblogs.com/2zly/" class="tooltipped" target="_blank" data-tooltip="关注我的博客园: https://www.cnblogs.com/2zly/" data-position="top" data-delay="50">
        <i class="fab fa-juejin">博</i>
    </a>
</div>
    </div>
</footer>

<div class="progress-bar"></div>




                                                                <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

                                                                    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


                                                                        <script
                                                                            src="/libs/materialize/materialize.min.js"></script>
                                                                        <script
                                                                            src="/libs/masonry/masonry.pkgd.min.js"></script>
                                                                        <script
                                                                            src="/libs/aos/aos.js"></script>
                                                                        <script
                                                                            src="/libs/scrollprogress/scrollProgress.min.js"></script>
                                                                        <script
                                                                            src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
                                                                        <script
                                                                            src="/js/matery.js"></script>
                                                                        <script
                                                                            src="/js/FunnyTitle.js"></script>



                                                                        

                                                                        <!-- Baidu Analytics -->

                                                                            <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

                                                                            
                                                                                
                                                                                    <script
                                                                                        src="/libs/others/clicklove.js"
                                                                                        async="async"></script> 
                                                                                     
                                                                                     <!--点击冒点-->
                                                                                    <canvas width="1777" height="841" style="position: fixed; left: 0px; top: 0px; z-index: 2147483647; pointer-events: none;"></canvas>
                                                                                    <script src="https://files.cnblogs.com/files/guixinchn/mouse-click.js"></script>
 
                                                                                        
                                                                                    
                                                                                    <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;" ></canvas> 
                                                                                    <script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> 
                                                                                        
                                                                                            <script async
                                                                                                src="/libs/others/busuanzi.pure.mini.js"></script>
                                                                                            

                                                                                                

                                                                                                        
                                                                                                            <script>
                                                                                                                (function (i, s, o, g, r, a, m) {
                                                                                                                    i["DaoVoiceObject"] = r;
                                                                                                                    i[r] = i[r] || function () {
                                                                                                                        (i[r].q = i[r].q || []).push(arguments)
                                                                                                                    }, i[r].l = 1 * new Date();
                                                                                                                    a = s.createElement(o), m = s.getElementsByTagName(o)[0];
                                                                                                                    a.async = 1;
                                                                                                                    a.src = g;
                                                                                                                    a.charset = "utf-8";
                                                                                                                    m.parentNode.insertBefore(a, m)
                                                                                                                })(window, document, "script", ('https:' == document.location.protocol ? 'https:' : 'http:') +
                                                                                                                    "//widget.daovoice.io/widget/6984b559.js", "daovoice")
                                                                                                                daovoice('init', {
                                                                                                                    app_id: "95264200000000"
                                                                                                                });
                                                                                                                daovoice('update');
                                                                                                            </script>
                                                                                                            
                                                                                                          

                                                                                                                
                                                                                                                    <div
                                                                                                                        style="position:fixed;bottom:135px;right:9px;cursor: pointer;">
                                                                                                                        <a title="兔小巢"
                                                                                                                            target="_blank" rel="noopener" href="https://support.qq.com/products/300304"><img
                                                                                                                                src="/medias/contact.png"></a>
                                                                                                                                
                                                                                                                    </div>
                                                                                                                    <div style="position:fixed;bottom:100px;right:1px;cursor: pointer;">
                                                                                                                        <a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=kzO2Zv0V3BZZuCXv54cFW_hKh6DFcULf&amp;jump_from=webapi"><img border="0" src="//pub.idqqimg.com/wpa/images/group.png" alt="CSDN博客💥IT交流社" title="CSDN博客💥IT交流社"></a>
                                                                                                                    </div>
                                                                                                                  
                                                                                                                    
                                                                                                                    
                                                                                                                        

                                                                                                                                



                                                                                                                                            
                                                                                                                                                <script
                                                                                                                                                    type="text/javascript"
                                                                                                                                                    src="/libs/background/ribbon-dynamic.js"
                                                                                                                                                    async="async"></script>
                                                                                                                                                

                                                                                                                                                    
                                                                                                                                                        <script
                                                                                                                                                            src="/libs/instantpage/instantpage.js"
                                                                                                                                                            type="module"></script>
                                                                                                                                                        
                                                                                                                                                            <meta
                                                                                                                                                                name="apple-mobile-web-app-capable"
                                                                                                                                                                content="yes" />
                                                                                                                                                            <meta
                                                                                                                                                                name="apple-mobile-web-app-status-bar-style"
                                                                                                                                                                content="black-translucent">
                                                                                                                                                            <meta
                                                                                                                                                                name="apple-mobile-web-app-title"
                                                                                                                                                                content="Color Draw">
                                                                                                                                                            <meta
                                                                                                                                                                name="viewport"
                                                                                                                                                                content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
                                                                                                                                                            <style>
                                                                                                                                                                html {
                                                                                                                                                                    cursor: url('https://i.loli.net/2020/12/18/oInyiJQHecmOjCf.png  '), auto;
                                                                                                                                                                }

                                                                                                                                                                .draw {
                                                                                                                                                                    position: fixed;
                                                                                                                                                                    width: 1px;
                                                                                                                                                                    line-height: 1px;
                                                                                                                                                                    pointer-events: none;
                                                                                                                                                                }

                                                                                                                                                                @keyframes floatOne {
                                                                                                                                                                    0% {
                                                                                                                                                                        opacity: 1;
                                                                                                                                                                    }

                                                                                                                                                                    50% {
                                                                                                                                                                        opacity: 1;
                                                                                                                                                                    }

                                                                                                                                                                    100% {
                                                                                                                                                                        opacity: 0;
                                                                                                                                                                        transform: translate3D(0, -20px, 0) scale(5) rotate(45deg);
                                                                                                                                                                    }
                                                                                                                                                                }
                                                                                                                                                            </style>

                                                                                                                                                            </head>

                                                                                                                                                            <body>


                                                                                                                                                            </body>
                                                                                                                                                          
                                                                                                                                                            

</html>

